<template>
<div>
    <el-form :model="inputForm" ref="inputForm" v-loading="loading"   :disabled="formReadOnly"
             label-width="120px">
      <el-row  :gutter="15">
        <el-col :span="24">
            <el-form-item label="序号" prop="basicdataCheckNumber"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCheckNumber" placeholder="请填写序号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="设备名称" prop="basicdataCheckFacility"
                :rules="[
                 ]">
              <el-input v-model="names" placeholder="请填写设备"     disabled=""></el-input>

           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="部件名称" prop="partsName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.partsName" placeholder="请填写部件名称"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="零件名称" prop="sparePartsName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparePartsName" placeholder="请填写零件名称"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="项目" prop="project"
                :rules="[
                 ]">
              <el-input v-model="inputForm.project" placeholder="请填写项目"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检内容" prop="checkContent"
                :rules="[
                 ]">
              <el-input v-model="inputForm.checkContent" placeholder="请填写点检内容"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="设备状态" prop="equipment"
                :rules="[
                 ]">
                    <el-radio-group v-model="inputForm.equipment">
                        <el-radio v-for="item in $dictUtils.getDictList('device_state')" :label="item.value" :key="item.id">{{item.label}}</el-radio>                    </el-radio-group>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检分工" prop="checkWork"
                :rules="[
                 ]">
                <el-checkbox-group
                        v-model="inputForm.checkWork">
                       <el-checkbox-button v-for="basicdataCheckJob in $dictUtils.getDictList('check_job')"  :label="basicdataCheckJob.value" :key="basicdataCheckJob.id">{{basicdataCheckJob.label}}</el-checkbox-button>
                    </el-checkbox-group>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检时间" prop="checkCycle"
                :rules="[
                 ]">
              <el-input v-model="inputForm.checkCycle" placeholder="请填写点检时间"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检" prop="basicdataCheckCheck"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCheckCheck" placeholder="请填写点检"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检单位" prop="basicdataCheckCheckUnit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCheckCheckUnit" placeholder="请填写点检单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检责任人" prop="checkUser.id"
                :rules="[
                 ]">
                <user-select :limit='1' :value="inputForm.checkUser.id" @getValue='(value) => {inputForm.checkUser.id=value}'></user-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检初始时间" prop="checkStartTime"
                :rules="[
                 ]">
                <el-date-picker
                      v-model="inputForm.checkStartTime"
                      type="datetime"
                      style="width: 100%;"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间">
                    </el-date-picker>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="检修时间" prop="overhaulCycle"
                :rules="[
                 ]">
                <el-date-picker
                      v-model="inputForm.overhaulCycle"
                      type="datetime"
                      style="width: 100%;"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间">
                    </el-date-picker>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="检修" prop="basicdataCheckFix"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCheckFix" placeholder="请填写检修"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="检修单位" prop="basicdataCheckFixUnit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.basicdataCheckFixUnit" placeholder="请填写检修单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="检修责任人" prop="overhaulUser.id"
                :rules="[
                 ]">
                <user-select :limit='1' :value="inputForm.overhaulUser.id" @getValue='(value) => {inputForm.overhaulUser.id=value}'></user-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="岗位时间" prop="overhaulStartTime"
                :rules="[
                 ]">
                <el-date-picker
                      v-model="inputForm.overhaulStartTime"
                      type="datetime"
                      style="width: 100%;"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      placeholder="选择日期时间">
                    </el-date-picker>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="岗位" prop="postCycle"
                :rules="[
                 ]">
              <el-input v-model="inputForm.postCycle" placeholder="请填写岗位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="岗位单位" prop="postUser"
                :rules="[
                 ]">
              <el-input v-model="inputForm.postUser" placeholder="请填写岗位单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="岗位责任人" prop="postStartTime.id"
                :rules="[
                 ]">
                <user-select :limit='1' :value="inputForm.postStartTime.id" @getValue='(value) => {inputForm.postStartTime.id=value}'></user-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检方法" prop="checkMethod"
                :rules="[
                 ]">
                <el-checkbox-group
                        v-model="inputForm.checkMethod">
                       <el-checkbox v-for="checkMethod in $dictUtils.getDictList('check_method')" :label="checkMethod.label" :key="checkMethod.id">{{checkMethod.value}}</el-checkbox>
                    </el-checkbox-group>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="内容" prop="checkName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.checkName" placeholder="请填写内容"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="类别" prop="category "
                :rules="[
                 ]">
                <el-select v-model="inputForm.category " placeholder="请选择"  style="width: 100%;">
                          <el-option
                            v-for="item in $dictUtils.getDictList('basicdata_category')"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                      </el-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="计量单位" prop="measurement"
                :rules="[
                 ]">
                <el-select v-model="inputForm.measurement" placeholder="请选择"  style="width: 100%;">
                          <el-option
                            v-for="item in $dictUtils.getDictList('basicdata_symbol_measure')"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                      </el-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="判断符号" prop="judgmentSymbol"
                :rules="[
                 ]">
                <el-select v-model="inputForm.judgmentSymbol" placeholder="请选择"  style="width: 100%;">
                          <el-option
                            v-for="item in $dictUtils.getDictList('basicdata_symbol')"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                      </el-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="上限" prop="upperLimit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.upperLimit" placeholder="请填写上限"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="极限" prop="limit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.limit" placeholder="请填写极限"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="判断" prop="ismanual"
                :rules="[
                 ]">
              <el-input v-model="inputForm.ismanual" placeholder="请填写判断"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="责任人" prop="checkStandard.id"
                :rules="[
                 ]">
                <user-select :limit='1' :value="inputForm.checkStandard.id" @getValue='(value) => {inputForm.checkStandard.id=value}'></user-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="点检责任人" prop="checkStandardRemaks.id"
                :rules="[
                 ]">
                <user-select :limit='1' :value="inputForm.checkStandardRemaks.id" @getValue='(value) => {inputForm.checkStandardRemaks.id=value}'></user-select>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="定性分析" prop="ration"
                :rules="[
                 ]">
              <el-input v-model="inputForm.ration" placeholder="请填写定性分析"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="备注信息" prop="remarks"
                :rules="[
                 ]">
          <el-input type="textarea" v-model="inputForm.remarks" placeholder="请填写备注信息"     ></el-input>
           </el-form-item>
        </el-col>
        </el-row>
    </el-form>
</div>
</template>

<script>
  import UserSelect from '@/components/userSelect'
  export default {
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        inputForm: {
          id: '',
          basicdataCheckNumber: '',
          equipmentName: '',
          partsName: '',
          sparePartsName: '',
          project: '',
          checkContent: '',
          equipment: '',
          checkWork: '',
          checkCycle: '',
          basicdataCheckCheck: '',
          basicdataCheckCheckUnit: '',
          checkUser: {
            id: ''
          },
          checkStartTime: '',
          overhaulCycle: '',
          basicdataCheckFix: '',
          basicdataCheckFixUnit: '',
          overhaulUser: {
            id: ''
          },
          overhaulStartTime: '',
          postCycle: '',
          postUser: '',
          postStartTime: {
            id: ''
          },
          checkMethod: '',
          checkName: '',
          category: '',
          measurement: '',
          judgmentSymbol: '',
          upperLimit: '',
          limit: '',
          ismanual: '',
          checkStandard: {
            id: ''
          },
          checkStandardRemaks: {
            id: ''
          },
          ration: '',
          remarks: ''
        }
      }
    },
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      }
    },
    components: {
      UserSelect
    },
    watch: {
      'businessId': {
        handler (newVal) {
          if (this.businessId) {
            this.init(this.businessId)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        },
        immediate: true,
        deep: false
      }
    },
    methods: {
      init (id) {
        if (id) {
          this.loading = true
          this.inputForm.id = id
          this.$nextTick(() => {
            this.$refs.inputForm.resetFields()
            this.$http({
              url: `/check/checkstandardprocess/checkStandard/queryById?id=${this.inputForm.id}`,
              method: 'get'
            }).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data.checkStandard)
              this.loading = false
            })
          })
        }
      },
      // 表单提交
      saveForm (callback) {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$http({
              url: `/check/checkstandardprocess/checkStandard/save`,
              method: 'post',
              data: this.inputForm
            }).then(({data}) => {
              if (data && data.success) {
                callback(data.businessTable, data.businessId)
              }
            })
          }
        })
      }
    }
  }
</script>
